/*
 * @Descripttion:
 * @version:
 * @Date: 2021-04-20 11:06:21
 * @LastEditors: huzhushan@126.com
 * @LastEditTime: 2021-04-21 09:36:55
 * @Author: huzhushan@126.com
 * @HomePage: https://huzhushan.gitee.io/vue3-element-admin
 * @Github: https://github.com/huzhushan/vue3-element-admin
 * @Donate: https://huzhushan.gitee.io/vue3-element-admin/donate/
 */
import request from '@/utils/request'

// 查询角色分页数据
//访问的后端接口，需要请求头携带token,请求参数携带keyword，路径携带pageNum+pageSize
export const GetSysRolePage = (keyword, pageNum, pageSize) => {
  return request({
    url: `/admin/system/role/page/${pageNum}/${pageSize}`,
    method: 'get',
    //价格keyword的值转换为json对象提交：如果传入的keyword为'系统',会转换为{"keyword"}
    params: { keyword }, //相当于使用keyword作为key 使用上面的keyword变量的值作为值
  })
}

export const DeleteSysRole = id => {
  return request({
    url: `/admin/system/role/${id}`,
    method: 'delete',
  })
}
//新增角色
export const SaveSysRole = data => {
  return request({
    url: `/admin/system/role`,
    method: 'post',
    data,
  })
}

//根据id查询
export const GetSysRoleById = id => {
  return request({
    url: `/admin/system/role/${id}`,
    method: 'get',
  })
}
//更新角色
export const UpdateSysRole = data => {
  return request({
    url: `/admin/system/role`,
    method: 'put',
    data,
  })
}

//根据用户id查询所有角色，和已分配的角色
export const GetAllSysRoles = userId => {
  return request({
    url: `/admin/system/role/all/${userId}`,
    method: 'get',
  })
}
